/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package service;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author andrew
 */
@Entity
@Table(name = "Connection")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Connection.findAll", query = "SELECT c FROM Connection c"),
    @NamedQuery(name = "Connection.findByIdConnection", query = "SELECT c FROM Connection c WHERE c.idConnection = :idConnection"),
    @NamedQuery(name = "Connection.findByDestinationPlanet", query = "SELECT c FROM Connection c WHERE c.destinationPlanet = :destinationPlanet"),
    @NamedQuery(name = "Connection.findByR", query = "SELECT c FROM Connection c WHERE c.r = :r"),
    @NamedQuery(name = "Connection.findByG", query = "SELECT c FROM Connection c WHERE c.g = :g"),
    @NamedQuery(name = "Connection.findByB", query = "SELECT c FROM Connection c WHERE c.b = :b")})
public class Connection implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idConnection")
    private Integer idConnection;
    @Basic(optional = false)
    @NotNull
    @Column(name = "destinationPlanet")
    private int destinationPlanet;
    @Basic(optional = false)
    @NotNull
    @Column(name = "r")
    private int r;
    @Basic(optional = false)
    @NotNull
    @Column(name = "g")
    private int g;
    @Basic(optional = false)
    @NotNull
    @Column(name = "b")
    private int b;
    @JoinColumn(name = "Planet_idPlanet", referencedColumnName = "idPlanet")
    @ManyToOne(optional = false)
    private Planet planetidPlanet;

    public Connection() {
    }

    public Connection(Integer idConnection) {
        this.idConnection = idConnection;
    }

    public Connection(Integer idConnection, int destinationPlanet, int r, int g, int b) {
        this.idConnection = idConnection;
        this.destinationPlanet = destinationPlanet;
        this.r = r;
        this.g = g;
        this.b = b;
    }

    public Integer getIdConnection() {
        return idConnection;
    }

    public void setIdConnection(Integer idConnection) {
        this.idConnection = idConnection;
    }

    public int getDestinationPlanet() {
        return destinationPlanet;
    }

    public void setDestinationPlanet(int destinationPlanet) {
        this.destinationPlanet = destinationPlanet;
    }

    public int getR() {
        return r;
    }

    public void setR(int r) {
        this.r = r;
    }

    public int getG() {
        return g;
    }

    public void setG(int g) {
        this.g = g;
    }

    public int getB() {
        return b;
    }

    public void setB(int b) {
        this.b = b;
    }

    public Planet getPlanetidPlanet() {
        return planetidPlanet;
    }

    public void setPlanetidPlanet(Planet planetidPlanet) {
        this.planetidPlanet = planetidPlanet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idConnection != null ? idConnection.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Connection)) {
            return false;
        }
        Connection other = (Connection) object;
        if ((this.idConnection == null && other.idConnection != null) || (this.idConnection != null && !this.idConnection.equals(other.idConnection))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "service.Connection[ idConnection=" + idConnection + " ]";
    }
    
}
